package com.mxpio.erp.common.purchase.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.model.BizOrderLine;
import com.mxpio.erp.common.technology.vo.ItemWithSubExtendsVO;
import com.mxpioframework.security.annotation.Dict;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_PURC_PO_LINE")
@Schema(description="采购订单行")
public class PurchaseOrderLine extends BizOrderLine {

	private static final long serialVersionUID = 1L;

	@Column(name = "PRICE_")
	@Schema(description = "单价")
	private BigDecimal price;

	@Column(name = "REQ_QUANTITY_")
	@Schema(description = "请购单数量")
	private BigDecimal reqQuantity;

	@Column(name = "ACCEPTANCE_STATUS_")
	@Schema(description = "是否检验")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String acceptanceStatus;

	@Column(name = "ACCEPTANCE_QUANTITY_")
	@Schema(description = "检验数量")
	private BigDecimal acceptanceQuantity;

	@Column(name = "QUALIFIED_QUANTITY_")
	@Schema(description = "合格数量")
	private BigDecimal qualifiedQuantity;

	@Column(name = "UNQUALIFIED_QUANTITY_")
	@Schema(description = "不合格数量")
	private BigDecimal unqualifiedQuantity;

	@Column(name = "PLANED_RECEIVING_")
	@Schema(description = "计划收货数")
	private BigDecimal planedReceiving;

	@Column(name = "ACTUAL_RECEIVING_")
	@Schema(description = "实际收货数")
	private BigDecimal actualReceiving;

	@Column(name = "PLANED_QUANTITY_")
	@Schema(description = "计划退货数")
	private BigDecimal planedReturns;

	@Schema(description = "建议下单日期")
	@Column(name = "SUGGEST_ORDER_DATE_")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date suggestOrderDate;

	@Schema(description = "建议到货日期")
	@Column(name = "SUGGEST_ARRIVE_DATE_")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date suggestArriveDate;

	@Column(name = "MEMO_")
	@Schema(description = "备注")
	private String memo;


	@Column(name = "TAX_RATE_")
	@Schema(description = "税率")
	private BigDecimal taxRate ;

	@Column(name = "TAX_PRICE_")
	@Schema(description = "含税单价")
	private BigDecimal taxPrice;

	@Column(name = "UNTAX_PRICE_")
	@Schema(description = "无税单价")
	private BigDecimal untaxPrice;

	@Column(name = "UNTAX_AMOUNT_")
	@Schema(description = "无税金额")
	private BigDecimal untaxAmount;

	@Column(name = "TAX_")
	@Schema(description = "税额")
	private BigDecimal tax;

	@Column(name = "TOTAL_AMOUNT")
	@Schema(description = "价税合计")
	private BigDecimal totalAmount;


	@Schema(description = "采购提前期")
	@Column(name = "ADVANCE_DAY_")
	private BigDecimal advanceDay;

	@Schema(description = "合同到货日期")
	@Column(name = "CONTRACT_ARRIVE_DATE_")
	@JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
	private Date contractArriveDate;

	@Column(name = "SHIPPING_ADDRESS_")
	@Schema(description = "发货地址")
	private String shippingAddress;

	@Column(name = "SHIPPING_MAN_")
	@Schema(description = "发货人")
	private String shippingMan;

	@Schema(description = "手机")
	@Column(name = "PHONE_")
	private String phone;

	@Schema(description = "请购单号")
	@Column(name = "REQ_BIZ_NO_")
	private String reqBizNo;


	@Schema(description = "请购单行号")
	@Column(name = "REQ_LINE_NO_")
	private String reqLineNo;

    @Transient
	private PurchaseOrder purchaseOrder;

/*	@Transient
	private BuyRequestOrderLine buyRequestOrderLine;*/

	@Transient
	@Schema(description = "请购单明细行建议下单日期")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date bRSuggestOrderDate;

	@Transient
	@Schema(description = "请购单明细行需求到货日期")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date bRArriveDate;

	@Transient
	private ItemWithSubExtendsVO item;//物料相关信息
}
